﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="${ctx}/assets/bootstrap-3.3.7-dist/css/bootstrap.min.css"
	rel="stylesheet">
<link href="${ctx}/assets/assets/css/base.css" rel="stylesheet">
<link href="${ctx}/assets/assets/css/m.css" rel="stylesheet">
<script src="${ctx}/assets/jquery/jquery2.2.4.min.js"></script>
<script src="${ctx}/assets/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<!-- 百度编辑器 -->
<script type="text/javascript" charset="utf-8"
	src="${ctx}/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8"
	src="${ctx}/ueditor/ueditor.all.js"></script>
<script type="text/javascript" charset="utf-8"
	src="${ctx}/ueditor/lang/zh-cn/zh-cn.js"></script>

<title>${user_detail.name}</title>
</head>
<body>
	<div class="ibox-content">
		<div class="row">
			
			<div class="row">
				<div class="col-md-12 col-lg-12 col-sm-12">
	
					<div class="col-md-12 col-lg-12 col-sm-12" style="border:1px solid red;">
						<div class="row">
							<c:if test="${user_detail.id == loginUser.id }">
								<div class="btn-group pull-right" style="margin: 10px 25px 0 0;">
									<a href="javascript:#" class="btn btn-primary"
										data-toggle="modal" data-target="#upload"><span
										class="bold">发布信息</span></a>
								</div>
							</c:if>
						</div>

						<c:forEach var="item" items="${filelist}">			
						 <div class="whitebg bloglist">
					      <ul>
					        <li>
					          <h3 class="blogtitle" onclick='gotoDetails("${ctx }/details","${item.fileDate}","${user_detail.name}",`${item.remark}`,"${item.title}")'>${item.title}</h3>
					           <span class="blogpic imgscale">
					           	<a href="#" title="">
					           		<img src="${ctx }/upload/${item.filePath }" onclick='gotoDetails("${ctx }/details","${item.fileDate}","${user_detail.name}",`${item.remark}`,"${item.title}")' />
					           	</a>
					           </span>
					           <!-- ${fn:substring(item.remark, 0, 120)}... -->
					          <div class="blogtext">${item.remark}...</div>
					          <p class="bloginfo">
					          	<span>${user_detail.name} </span>
					          	<span>${item.fileDate}</span>
					          	<a href="${ctx }/deleteFile?id=${item.id}&token=${user_detail.id}" class="btn btn-outline btn-danger btn-xs">删除</a>
					          </p>
					          <a href="#" class="viewmore" onclick='gotoDetails("${ctx }/details","${item.fileDate}","${user_detail.name}",`${item.remark}`,"${item.title}")' >阅读更多</a>
					        </li>
					      </ul>
					    </div>
						</c:forEach>
							
								
						
					</div>
				</div>
			</div>
		</div>
	</div>
	<!--
		修改信息
	-->
	<div class="modal inmodal fade" id="upload" tabindex="-1" role="dialog"
		aria-hidden="true">
		<div class="modal-dialog" style="width:800px;">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">
						<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
					</button>
					<h4 class="modal-title">上传资料</h4>
				</div>
				<form name="detailsform" class="form-horizontal" action="${ctx }/uploadFile"
					method="post" enctype="multipart/form-data" onSubmit="return check();">
					<div class="modal-body">
						<input type="hidden" class="form-control" name="token" id="token"
							value="${user_detail.id}">
							<div class="form-group">
							<label class="col-sm-2 control-label">请输入图片：</label>
							<div class="col-sm-9">
								<input type="file" class="form-control" name="myfile"
									id="myfile">
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">标题：</label>
							<div class="col-sm-9">
								<input type="text" class="form-control" name="title" id="title">
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">描述：</label>
							<div class="col-sm-9">
							<script type="text/plain" id="name" name="name"></script>
								<!-- <textarea rows=10 class="form-control" name="name" id="name"></textarea> -->
							</div>
						</div>
						<!--
						<div class="form-group">
							<label class="col-sm-2 control-label">描述：</label>
							<div class="col-sm-10">
								<div id="editor" name="name" id="name"></div>
							</div>
						</div> -->
						
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
						<input type="submit" class="btn btn-primary" value="确认添加" />
					</div>
				</form>
			</div>
		</div>
	</div>
</body>
<script src="${ctx}/assets/js/wangEditor.min.js"></script>
<script type="text/javascript">
	var editor = new UE.ui.Editor();
	//1.2.4以后可以使用一下代码实例化编辑器 
	UE.getEditor('name', {
	    toolbars: [
	        [
	        	//'anchor', //锚点
	            'undo', //撤销
	            'redo', //重做
	            'bold', //加粗
	            'indent', //首行缩进
	           // 'snapscreen', //截图
	            'italic', //斜体
	            'underline', //下划线
	            //'strikethrough', //删除线
	            //'subscript', //下标
	            //'fontborder', //字符边框
	            //'superscript', //上标
	            //'formatmatch', //格式刷
	           // 'source', //源代码
	            //'blockquote', //引用
	            //'pasteplain', //纯文本粘贴模式
	            //'selectall', //全选
	            //'print', //打印
	            //'preview', //预览
	           // 'horizontal', //分隔线
	            'removeformat', //清除格式
	            //'time', //时间
	            //'date', //日期
	            'unlink', //取消链接
	            //'insertrow', //前插入行
	           // 'insertcol', //前插入列
	           // 'mergeright', //右合并单元格
	           // 'mergedown', //下合并单元格
	            //'deleterow', //删除行
	            //'deletecol', //删除列
	            //'splittorows', //拆分成行
	           // 'splittocols', //拆分成列
	           // 'splittocells', //完全拆分单元格
	           // 'deletecaption', //删除表格标题
	           // 'inserttitle', //插入标题
	           // 'mergecells', //合并多个单元格
	           // 'deletetable', //删除表格
	           // 'cleardoc', //清空文档
	           // 'insertparagraphbeforetable', //"表格前插入行"
	           // 'insertcode', //代码语言
	            'fontfamily', //字体
	            'fontsize', //字号
	           // 'paragraph', //段落格式
	            'simpleupload', //单图上传
	           // 'insertimage', //多图上传
	           // 'edittable', //表格属性
	           // 'edittd', //单元格属性
	            //'link', //超链接
	           // 'emotion', //表情
	           // 'spechars', //特殊字符
	            //'searchreplace', //查询替换
	            //'map', //Baidu地图
	            //'gmap', //Google地图
	           // 'insertvideo', //视频
	          //  'help', //帮助
	            'justifyleft', //居左对齐
	            'justifyright', //居右对齐
	            'justifycenter', //居中对齐
	            'justifyjustify', //两端对齐
	            'forecolor', //字体颜色
	            'backcolor', //背景色
	            'insertorderedlist', //有序列表
	            'insertunorderedlist', //无序列表
	            //'fullscreen', //全屏
	           // 'directionalityltr', //从左向右输入
	           // 'directionalityrtl', //从右向左输入
	            //'rowspacingtop', //段前距
	           // 'rowspacingbottom', //段后距
	           // 'pagebreak', //分页
	           // 'insertframe', //插入Iframe
	            'imagenone', //默认
	            'imageleft', //左浮动
	            'imageright', //右浮动
	            'attachment', //附件
	            'imagecenter', //居中
	            'wordimage', //图片转存
	            'lineheight', //行间距
	           // 'edittip ', //编辑提示
	            //'customstyle', //自定义标题
	           // 'autotypeset', //自动排版
	            //'webapp', //百度应用
	            'touppercase', //字母大写
	            'tolowercase', //字母小写
	            'background' //背景
	           // 'template', //模板
	           // 'scrawl', //涂鸦
	           // 'music', //音乐
	          //  'inserttable', //插入表格
	           // 'drafts', // 从草稿箱加载
	            //'charts', // 图
	    ]
	],
	    autoHeightEnabled: true,
	    autoFloatEnabled: true
	});

  //var E = window.wangEditor
 // var editor = new E('#editor')
//  editor.customConfig.menus = [
 //   'head',
 //   'bold',
 //   'fontSize',
 //   'fontName',
 //   'italic',
 //   'underline',
 //   'strikeThrough',
  //  'foreColor',
  //  'link',
  //  'list',
  //  'justify',
  //  'quote',
 //   'image',
  //  'table',
  //  'undo',
  //  'redo'
  //]
  //editor.customConfig.uploadImgShowBase64 = true   // 使用 base64 保存图片
 // editor.customConfig.uploadImgServer = '/upload'  // 上传图片到服务器
 //  editor.customConfig.onchange = function (html) {
 //    监控变化，同步更新到 textarea
 //   document.detailsform.name.value = html
 // }
 // editor.create();

  //表单验证
  function check(){
  	if (document.detailsform.myfile.value === '') {
  		alert("图片不能为空");        
      return false; 
  	} else {
  		if (document.detailsform.title.value === '')    {        
	      alert("标题不能为空");        
	      return false;    
	    } else {
		    // console.log(document.detailsform.name.value)
	    	if (document.detailsform.name.value === undefined || document.detailsform.name.value === "") {
	    		alert("描述不能为空");
	    		return false;
	    	} else {
	    		return true;
	    	}
	    }
  	}
	}

	// window.onload = function () {
	function myfilter (content) {
		console.log(content);
		// var reTag = /<img(?:.|\s)*?>/g;
		// console.log(content.replace(reTag,''));
		// return content.replace(reTag,'')
		// console.log(document.getElementById("remark").innerHTML)
		// document.getElementById("remark").innerHTML = content.replace(reTag,'');
	}
	// }
	// function myfilter (content) {
	// 	var text=content.replace(/<\/?.+?>/g,"");
	// 	var newtext=text.replace(/ /g,"");//dds为得到后的内容
	// 	console.log(newtext);
	// }
	function gotoDetails (url,fileDate,name,remark,title) {
		sessionStorage.fileDate = fileDate;
		sessionStorage.name = name;
		sessionStorage.title = title;
		sessionStorage.remark = remark;
		window.location.href = url;
		console.log("onclick")
	}
</script>
<style type="text/css">
	p {
		margin: 0;
	}
	.w-e-text {
    padding: 0px 20px;
    overflow-y: scroll;
	}
/*	.blogtext{
		overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
	}*/
</style>
</html>